let vue = new Vue({
    el: '.main-content',
    data:{
            result: {},
            officeName:'',
        newUser:{},
        userCondition:{
                name:'',
                rname:'',
                phone:''
        }
    },
            methods: {
                selectByCondition: function (pageNum, pageSize) {
                    axios({
                        url: `sysuser/index/${pageNum}/${pageSize}`,
                        method:'post',
                        data:this.userCondition
                    }).then(rs => {
                        this.result = rs.data.obj;
                    })
                },
                select: function (pageNum, pageSize) {
                    axios({
                        url: `sysuser/index/${pageNum}/${pageSize}`,
                        method:'post',
                        data:this.userCondition
                    }).then(rs => {
                        this.result = rs.data.obj;
                    })
                },
                detailView: function (o) {
                    layer.user=o;
                    layer.message = '';
                    layer.open({
                        type: 2,
                        title: false,
                        area: ['80%', '80%'],
                        content: 'sysuser/detail',
                        end:()=>{
                            if (layer.message!=''){
                                layer.msg(layer.message)
                            }
                        }
                    })
                },
                update: function (o) {
                    layer.user=o;
                    layer.message = '';
                    layer.open({
                        type: 2,
                        title: false,
                        area: ['80%', '80%'],
                        content: 'sysuser/update',
                        end:()=>{
                            if (layer.message!=""){
                                layer.msg("更新成功");
                                this.userCondition={
                                    name:'',
                                    rname:'',
                                    phone:''
                                };
                                this.select(1,5)
                            }
                        }
                    })
                },
                deleteOne:function (o) {
                    axios({
                        url:'sysuser/deleteOne',
                        method:'put',
                        data:o
                    }).then(rs=>{
                        if(rs.data.success){
                            layer.msg(rs.data.msg);
                            this.userCondition={
                                name:'',
                                    rname:'',
                                    phone:''
                            };
                            this.select(1,5);
                        }
                    })
                },
                save:function () {
                    axios({
                        url:'saveOne',
                        method:'post',
                        data:this.newUser
                    }).then(rs=>{
                        if (rs.data.success) {
                            layer.msg(rs.data.msg)
                        }
                    })
                }
        }
    ,
    created: function () {
        this.select(1,5);
    }
});